package org.jtao.gbsubject.service.mapper;

import org.jtao.gbsubject.domain.*;
import org.jtao.gbsubject.service.dto.CurrentStateDTO;

import org.mapstruct.*;

/**
 * Mapper for the entity CurrentState and its DTO CurrentStateDTO.
 */
@Mapper(componentModel = "spring", uses = {SubjectMapper.class, IndicatorMapper.class})
public interface CurrentStateMapper extends EntityMapper<CurrentStateDTO, CurrentState> {

    @Mapping(source = "subject.id", target = "subjectId")
    @Mapping(source = "subject.name", target = "subjectName")
    @Mapping(source = "indicator.id", target = "indicatorId")
    @Mapping(source = "indicator.name", target = "indicatorName")
    CurrentStateDTO toDto(CurrentState currentState);

    @Mapping(source = "subjectId", target = "subject")
    @Mapping(source = "indicatorId", target = "indicator")
    CurrentState toEntity(CurrentStateDTO currentStateDTO);

    default CurrentState fromId(Long id) {
        if (id == null) {
            return null;
        }
        CurrentState currentState = new CurrentState();
        currentState.setId(id);
        return currentState;
    }
}
